/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package slicktemplate;

import java.awt.geom.Point2D;
import org.newdawn.slick.Input;
import org.newdawn.slick.MouseListener;

/**
 *
 * @author student
 */
public class BetterMouseListener implements MouseListener {

    private boolean acceptInput = true;
    private boolean[] mouseArray = new boolean[3];
    private Point2D.Float mousePosition = new Point2D.Float();

    @Override
    public void mouseWheelMoved(int change) {
    }

    @Override
    public void mouseClicked(int button, int x, int y, int clickCount) {
    }

    @Override
    public void mousePressed(int button, int x, int y) {
        switch (button) {
            case 0:
                mouseArray[0] = true;
                System.out.println("Left button pressed");
                break;
            case 1:
                mouseArray[1] = true;
                System.out.println("Right button pressed");
                break;
            case 2:
                mouseArray[2] = true;
                System.out.println("Middle button pressed");
                break;
            default:
                throw new AssertionError();
        }
    }

    @Override
    public void mouseReleased(int button, int x, int y) {
    }

    @Override
    public void mouseMoved(int oldx, int oldy, int newx, int newy) {
        mousePosition = new Point2D.Float(newx, newy);
    }

    @Override
    public void mouseDragged(int oldx, int oldy, int newx, int newy) {
    }

    @Override
    public void setInput(Input input) {
    }

    @Override
    public boolean isAcceptingInput() {
        return acceptInput;
    }

    @Override
    public void inputEnded() {
    }

    public void reset() {
        for (int i = 0; i < mouseArray.length; i++) {
            mouseArray[i] = false;

        }
    }

    @Override
    public void inputStarted() {
    }

    public boolean isMousePressed(int button, boolean calledThisLoop) {//Gonna try this, now it should check by object
        if (calledThisLoop) {
            return false;
        }
        return mouseArray[button];
    }
}
